package scala.day03

import scala.io.Source

object Demo10Implicit {
  def main(args: Array[String]): Unit = {
    /**
      * 隐式转化类
      */
    val students: List[String] = Source.fromFile("data/students.txt").getLines().toList

    val strings: List[String] = new FileRead("data/students.txt").read()

    val list: List[String] = "data/students.txt".read()
    list.foreach(println)

    /**
      * 隐式转换
      * 动态给对象增加新的方法
      *
      */

  }
  /**
    * 隐式转化类
    * 可以将构造函数参数的类型隐式转化当前类
    */
  implicit class FileRead(path:String){
    def read(): List[String] ={
      Source.fromFile(path).getLines().toList
    }
  }
}
